package com.fly.caihong.utils;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * 创建时间：2018/5/23 0023 13:19
 * 创建人：fly
 * 功能描述：RecyclerView item间距
 */
public class ItemSpacesDecoration extends RecyclerView.ItemDecoration {

    private int left, top, right, bottom;

    /**
     * 间距值，单位dp
     *
     * @param left
     * @param top
     * @param right
     * @param bottom
     */
    public ItemSpacesDecoration(int left, int top, int right, int bottom) {
        this.left = SizeUtils.dp2px(left);
        this.right = SizeUtils.dp2px(right);
        this.top = SizeUtils.dp2px(top);
        this.bottom = SizeUtils.dp2px(bottom);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.left = this.left;
        outRect.right = this.right;
        outRect.top = this.top;
        outRect.bottom = this.bottom;
    }

}